﻿using System;
using System.Windows.Forms;

namespace ResxHelper.Logic
{
    public class DialogHelper
    {
        public static string GetSaveFileLocation(string filter, out DialogResult result, string defaultName = null)
        {
            var d = new SaveFileDialog {Filter = filter, FileName = defaultName};
            result = d.ShowDialog();
            return result == DialogResult.OK
                       ? d.FileName
                       : String.Empty;
        }

        public static string PromptForFile(string filter = null)
        {
            var dialog = new OpenFileDialog {Filter = filter};
            var file = String.Empty;
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                file = dialog.FileName;
            }

            return file;
        }

        public static string GetSaveDirectory()
        {
            var d = new FolderBrowserDialog();
            var result = d.ShowDialog();
            return result == DialogResult.OK
                       ? d.SelectedPath
                       : String.Empty;
        }
    }
}
